package com.bruce.asurada.sso.client.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * SSO配置属性
 * 
 * @author Bruce
 */
@Data
@Component
@ConfigurationProperties(prefix = "sso")
public class SsoProperties {

    /**
     * SSO服务端URL
     */
    private String serverUrl;
    
    /**
     * 客户端ID
     */
    private String clientId;
    
    /**
     * 客户端密钥
     */
    private String clientSecret;
    
    /**
     * 重定向URI
     */
    private String redirectUri;
    
    /**
     * 登录页面路径
     */
    private String loginPage = "/login";
    
    /**
     * 登录成功后跳转页面
     */
    private String successPage = "/";
    
    /**
     * 登出成功后跳转页面
     */
    private String logoutSuccessPage = "/";

    private Server server = new Server();
    private Client client = new Client();

    /**
     * 获取服务端URL（兼容方法）
     */
    public String getServerUrl() {
        return this.serverUrl != null ? this.serverUrl : this.server.baseUrl;
    }

    @Data
    public static class Server {
        private String baseUrl;
        private String loginUrl;
        private String verifyUrl;
        private String checkUrl;
        private String logoutUrl;
        private String refreshUrl;
        private String userinfoUrl;
    }

    @Data
    public static class Client {
        private String id;
        private String name;
        private String redirectUri;
        private String logoutRedirectUri;
    }
}